package com.dyp.websocket.resource;

import com.dyp.websocket.endpoint.FirstWebSocketHandler;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.io.IOException;

@RestController
@RequestMapping(value = "/api")
public class TestResource {
    @GetMapping("/test/{name}")
    public void hello(@PathVariable("name")String name) throws IOException {
        FirstWebSocketHandler.remoteEdnpoints.get(name).sendText("hello: " +name);
    }

}
